fitpack_surface Derived Type

type, public :: fitpack_surface

A public type describing a surface fitter z = s(x,y)


Components

Type Visibility Attributes Name Initial
integer, public :: bc = OUTSIDE_NEAREST_BND
real(kind=RKIND), public, allocatable :: c(:)
real(kind=RKIND), public :: fp = zero
integer, public :: iopt = 0
integer, public, allocatable :: iwrk(:)
integer, public :: knots(2) = 0
real(kind=RKIND), public :: left(2)

Interval boundaries

integer, public :: liwrk = 0
integer, public :: lwrk1 = 0
integer, public :: lwrk2 = 0
integer, public :: m = 0

The data points

integer, public :: nest(2) = 0
integer, public :: nmax = 0
integer, public :: order(2) = 3

Spline degree

real(kind=RKIND), public :: right(2)

Interval boundaries

real(kind=RKIND), public :: smoothing = 1000.d0
real(kind=RKIND), public, allocatable :: t(:,:)
real(kind=RKIND), public, allocatable :: w(:)
real(kind=RKIND), public, allocatable :: wrk1(:)
real(kind=RKIND), public, allocatable :: wrk2(:)
real(kind=RKIND), public, allocatable :: x(:)
real(kind=RKIND), public, allocatable :: y(:)
real(kind=RKIND), public, allocatable :: z(:)

Constructor

public interface fitpack_surface

  • private function surf_new_from_points(x, y, z, w, ierr) result(this)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=RKIND), intent(in) :: x(:)
    real(kind=RKIND), intent(in) :: y(size(x))
    real(kind=RKIND), intent(in) :: z(size(x))
    real(kind=RKIND), intent(in), optional :: w(size(x))
    integer, intent(out), optional :: ierr

    Return Value type(fitpack_surface)


Type-Bound Procedures

procedure, public :: destroy => surf_destroy

Clean memory

  • private elemental subroutine surf_destroy(this)

    Arguments

    Type IntentOptional Attributes Name
    class(fitpack_surface), intent(inout) :: this

procedure, public :: fit => surface_fit_automatic_knots

Generate/update fitting curve, with optional smoothing

  • private function surface_fit_automatic_knots(this, smoothing, order) result(ierr)

    Arguments

    Type IntentOptional Attributes Name
    class(fitpack_surface), intent(inout) :: this
    real(kind=RKIND), intent(in), optional :: smoothing
    integer, intent(in), optional :: order

    Return Value integer

procedure, public :: new_fit => surf_new_fit

Generate new fit

  • private function surf_new_fit(this, x, y, z, w, smoothing, order)

    Arguments

    Type IntentOptional Attributes Name
    class(fitpack_surface), intent(inout) :: this
    real(kind=RKIND), intent(in) :: x(:)
    real(kind=RKIND), intent(in) :: y(size(x))
    real(kind=RKIND), intent(in) :: z(size(x))
    real(kind=RKIND), intent(in), optional :: w(size(x))
    real(kind=RKIND), intent(in), optional :: smoothing
    integer, intent(in), optional :: order

    Return Value integer

procedure, public :: new_points => surf_new_points

Set new points

  • private subroutine surf_new_points(this, x, y, z, w)

    Arguments

    Type IntentOptional Attributes Name
    class(fitpack_surface), intent(inout) :: this
    real(kind=RKIND), intent(in) :: x(:)
    real(kind=RKIND), intent(in) :: y(size(x))
    real(kind=RKIND), intent(in) :: z(size(x))
    real(kind=RKIND), intent(in), optional :: w(size(x))

Source Code

    type :: fitpack_surface

        !> The data points
        integer :: m = 0
        real(RKIND), allocatable :: x(:),y(:),z(:)

        !> Spline degree
        integer :: order(2) = 3

        !> Interval boundaries
        real(RKIND) :: left(2),right(2)

        ! Node weights
        real(RKIND), allocatable :: w(:)

        ! Estimated and actual number of knots and their allocations
        integer :: nest(2)  = 0
        integer :: nmax = 0
        integer                  :: lwrk1 = 0, lwrk2 = 0, liwrk = 0
        integer, allocatable     :: iwrk(:)
        real(RKIND), allocatable :: wrk1(:),wrk2(:)

        ! Curve fit smoothing parameter (fit vs. points MSE)
        real(RKIND) :: smoothing = 1000.d0

        ! Actual curve MSE
        real(RKIND) :: fp = zero

        ! Curve extrapolation behavior
        integer     :: bc = OUTSIDE_NEAREST_BND

        ! Knots
        integer     :: knots(2) = 0
        real(RKIND), allocatable :: t(:,:) ! Knot locations (:,1)=x; (:,2)=y

        ! Spline coefficients [knots-order-1]
        real(RKIND), allocatable :: c(:)

        ! Runtime flag
        integer :: iopt = 0


        contains


           !> Clean memory
           procedure :: destroy    => surf_destroy

           !> Set new points
           procedure :: new_points => surf_new_points

           !> Generate new fit
           procedure :: new_fit    => surf_new_fit

           !> Generate/update fitting curve, with optional smoothing
           procedure :: fit        => surface_fit_automatic_knots

    end type fitpack_surface